home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / gnu / autoconf.lha / autoconf-1.4 / acgeneral.m4 < prev    next >
Text File  |  1993-05-22  |  22KB  |  742 lines

  1. dnl Parameterized macros that do not check for something specific.
  2. dnl This file is part of Autoconf.
  3. dnl Copyright (C) 1992, 1993 Free Software Foundation, Inc.
  4. dnl
  5. dnl This program is free software; you can redistribute it and/or modify
  6. dnl it under the terms of the GNU General Public License as published by
  7. dnl the Free Software Foundation; either version 2, or (at your option)
  8. dnl any later version.
  9. dnl
  10. dnl This program is distributed in the hope that it will be useful,
  11. dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. dnl GNU General Public License for more details.
  14. dnl
  15. dnl You should have received a copy of the GNU General Public License
  16. dnl along with this program; if not, write to the Free Software
  17. dnl Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18. dnl
  19. dnl Written by David MacKenzie, with help from
  20. dnl Franc,ois Pinard, Karl Berry, Richard Pixley, and Ian Lance Taylor.
  21. dnl
  22. changequote([,])dnl
  23. undefine([eval])dnl
  24. undefine([include])dnl
  25. undefine([shift])dnl
  26. dnl
  27. dnl
  28. dnl Utility functions for stamping the configure script.
  29. dnl
  30. dnl
  31. define(AC_ACVERSION, 1.4)dnl
  32. dnl This is defined by the --version option of the autoconf script.
  33. ifdef([AC_PRINT_VERSION], [errprint(Autoconf version AC_ACVERSION
  34. )])dnl
  35. dnl
  36. dnl These are currently not used, for the sake of people who diff
  37. dnl configure scripts and don't want spurious differences.
  38. dnl But they are too clever to just delete.
  39. dnl
  40. define(AC_USER, [esyscmd(
  41. changequote({,})dnl
  42. # Extract the user name from the first pair of parentheses.
  43. ({sedcmd='s/[^(]*(\([^)]*\)).*/\1/';}
  44. changequote([,])dnl
  45. whoami || id|sed "$sedcmd") 2>/dev/null|tr -d '\012')])dnl
  46. dnl
  47. define(AC_HOST, [esyscmd((hostname || uname -n) 2>/dev/null|tr -d '\012')])dnl
  48. dnl
  49. define(AC_DATE, [esyscmd(date|tr -d '\012')])dnl
  50. dnl
  51. dnl
  52. dnl Controlling Autoconf operation
  53. dnl
  54. dnl
  55. dnl This is separate from AC_INIT to prevent GNU m4 1.0 from coredumping
  56. dnl when AC_CONFIG_HEADER is used.
  57. define(AC_NOTICE,
  58. [# Guess values for system-dependent variables and create Makefiles.
  59. # Generated automatically using autoconf.
  60. dnl [#] Generated automatically using autoconf version AC_ACVERSION
  61. dnl [#] by AC_USER@AC_HOST on AC_DATE
  62. # Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc.
  63.  
  64. # This program is free software; you can redistribute it and/or modify
  65. # it under the terms of the GNU General Public License as published by
  66. # the Free Software Foundation; either version 2, or (at your option)
  67. # any later version.
  68.  
  69. # This program is distributed in the hope that it will be useful,
  70. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  71. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  72. # GNU General Public License for more details.
  73.  
  74. # You should have received a copy of the GNU General Public License
  75. # along with this program; if not, write to the Free Software
  76. # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  77.  
  78. # Usage: configure [--srcdir=DIR] [--host=HOST] [--gas] [--nfp] [--no-create]
  79. #        [--prefix=PREFIX] [--exec-prefix=PREFIX] [--with-PACKAGE] [TARGET]
  80. # Ignores all args except --srcdir, --prefix, --exec-prefix, --no-create, and
  81. # --with-PACKAGE unless this script has special code to handle it.
  82. ])dnl
  83. dnl
  84. define(AC_PARSEARGS,[
  85. for arg
  86. do
  87.   # Handle --exec-prefix with a space before the argument.
  88.   if test x$next_exec_prefix = xyes; then exec_prefix=$arg; next_exec_prefix=
  89.   # Handle --host with a space before the argument.
  90.   elif test x$next_host = xyes; then next_host=
  91.   # Handle --prefix with a space before the argument.
  92.   elif test x$next_prefix = xyes; then prefix=$arg; next_prefix=
  93.   # Handle --srcdir with a space before the argument.
  94.   elif test x$next_srcdir = xyes; then srcdir=$arg; next_srcdir=
  95.   else
  96.     case $arg in
  97.      # For backward compatibility, also recognize exact --exec_prefix.
  98.      -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* | --exec=* | --exe=* | --ex=* | --e=*)
  99. changequote(,)dnl
  100.     exec_prefix=`echo $arg | sed 's/[-a-z_]*=//'` ;;
  101. changequote([,])dnl
  102.      -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- | --exec | --exe | --ex | --e)
  103.     next_exec_prefix=yes ;;
  104.  
  105.      -gas | --gas | --ga | --g) ;;
  106.  
  107.      -host=* | --host=* | --hos=* | --ho=* | --h=*) ;;
  108.      -host | --host | --hos | --ho | --h)
  109.     next_host=yes ;;
  110.  
  111.      -nfp | --nfp | --nf) ;;
  112.  
  113.      -no-create | --no-create | --no-creat | --no-crea | --no-cre | --no-cr | --no-c | --no- | --no)
  114.         no_create=1 ;;
  115.  
  116.      -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
  117. changequote(,)dnl
  118.     prefix=`echo $arg | sed 's/[-a-z_]*=//'` ;;
  119. changequote([,])dnl
  120.      -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
  121.     next_prefix=yes ;;
  122.  
  123.      -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=* | --s=*)
  124. changequote(,)dnl
  125.     srcdir=`echo $arg | sed 's/[-a-z_]*=//'` ;;
  126. changequote([,])dnl
  127.      -srcdir | --srcdir | --srcdi | --srcd | --src | --sr | --s)
  128.     next_srcdir=yes ;;
  129.  
  130.      -with-* | --with-*)
  131.        package=`echo $arg|sed 's/-*with-//'`
  132.        # Delete all the valid chars; see if any are left.
  133. changequote(,)dnl
  134.        if test -n "`echo $package|sed 's/[-a-zA-Z0-9_]*//g'`"; then
  135. changequote([,])dnl
  136.          echo "configure: $package: invalid package name" >&2; exit 1
  137.        fi
  138.        eval "with_`echo $package|sed s/-/_/g`=1" ;;
  139.  
  140.      -v | -verbose | --verbose | --verbos | --verbo | --verb | --ver | --ve | --v)
  141.        verbose=yes ;;
  142.  
  143.      *) ;;
  144.     esac
  145.   fi
  146. done
  147. ])dnl
  148. dnl
  149. define(AC_INIT,
  150. [#!/bin/sh
  151. AC_NOTICE
  152. AC_PARSEARGS
  153. AC_PREPARE($1)])dnl
  154. dnl
  155. define(AC_PREPARE,
  156. [trap 'rm -f conftest* core; exit 1' 1 3 15
  157.  
  158. # Needed for some versions of `tr' so that character classes in `[]' work.
  159. if test "${LANG+set}" = "set" ; then
  160.    LANG=C
  161. fi
  162.  
  163. rm -f conftest*
  164. compile='${CC-cc} $CFLAGS $DEFS conftest.c -o conftest $LIBS >/dev/null 2>&1'
  165.  
  166. # A filename unique to this package, relative to the directory that
  167. # configure is in, which we can look for to find out if srcdir is correct.
  168. unique_file=$1
  169.  
  170. # Find the source files, if location was not specified.
  171. if test -z "$srcdir"; then
  172.   srcdirdefaulted=yes
  173.   # Try the directory containing this script, then `..'.
  174.   prog=[$]0
  175. changequote(,)dnl
  176.   confdir=`echo $prog|sed 's%/[^/][^/]*$%%'`
  177. changequote([,])dnl
  178.   test "X$confdir" = "X$prog" && confdir=.
  179.   srcdir=$confdir
  180.   if test ! -r $srcdir/$unique_file; then
  181.     srcdir=..
  182.   fi
  183. fi
  184. if test ! -r $srcdir/$unique_file; then
  185.   if test x$srcdirdefaulted = xyes; then
  186.     echo "configure: Can not find sources in \`${confdir}' or \`..'." 1>&2
  187.   else
  188.     echo "configure: Can not find sources in \`${srcdir}'." 1>&2
  189.   fi
  190.   exit 1
  191. fi
  192. # Preserve a srcdir of `.' to avoid automounter screwups with pwd.
  193. # But we can't avoid them for `..', to make subdirectories work.
  194. case $srcdir in
  195.   .|/*|~*) ;;
  196.   *) srcdir=`cd $srcdir; pwd` ;; # Make relative path absolute.
  197. esac
  198. ])dnl
  199. dnl
  200. dnl Protects the argument from being diverted twice
  201. dnl if this macro is called twice for it.
  202. dnl Diversion 0 is the normal output.
  203. dnl Diversion 1 is sed substitutions for output files.
  204. dnl Diversion 2 is variable assignments for config.status.
  205. define(AC_SUBST,
  206. [ifdef([AC_SUBST_$1], ,
  207. [define([AC_SUBST_$1], )dnl
  208. divert(1)dnl
  209. s%@$1@%[$]$1%g
  210. divert(2)dnl
  211. $1='[$]$1'
  212. divert(0)dnl
  213. ])])dnl
  214. dnl
  215. define(AC_WITH,
  216. [[#] check whether --with-$1 was given
  217. if test -n "[$with_]patsubst($1,-,_)"; then
  218.   ifelse([$2], , :, [$2])
  219. ifelse([$3], , , [else
  220.   $3
  221. ])dnl
  222. fi
  223. ])dnl
  224. dnl
  225. dnl Guess the value for the `prefix' variable by looking for
  226. dnl the argument program along PATH and taking its parent.
  227. dnl Example: if the argument is `gcc' and we find /usr/local/gnu/bin/gcc,
  228. dnl set `prefix' to /usr/local/gnu.
  229. define(AC_PREFIX,
  230. [if test -z "$prefix"
  231. then
  232.   echo checking for $1 to derive installation directory prefix
  233.   IFS="${IFS=     }"; saveifs="$IFS"; IFS="$IFS:"
  234.   for dir in $PATH; do
  235.     test -z "$dir" && dir=.
  236.     if test $dir != . && test -f $dir/$1; then
  237. changequote(,)dnl
  238.       # Not all systems have dirname.
  239.       prefix=`echo $dir|sed 's%/[^/][^/]*$%%'`
  240. changequote([,])dnl
  241.       break
  242.     fi
  243.   done
  244.   IFS="$saveifs"
  245.   echo "    chose installation directory prefix ${prefix}"
  246. fi
  247. ])dnl
  248. dnl
  249. define(AC_CONFIG_HEADER, [define(AC_CONFIG_NAME, $1)])dnl
  250. dnl
  251. dnl Several simple subroutines to do various flavors of quoting.
  252. dnl
  253. dnl Quote $1 against shell "s.
  254. define(AC_QUOTE_DQUOTE, [dnl We use \1 instead of \& to avoid an m4 1.0.3 bug.
  255. patsubst($1, changequote(,)\([$"`\\]\)changequote([,]), \\\1)])dnl
  256. dnl
  257. dnl Quote $1 against shell 's.
  258. define(AC_QUOTE_SQUOTE, [patsubst($1, ', '\\'')])dnl
  259. dnl
  260. dnl Quote $1 against shell here documents (<<EOF).
  261. define(AC_QUOTE_HERE, [changequote({,})dnl
  262. dnl We use \1 instead of \& to avoid an m4 1.0.3 bug.
  263. patsubst(patsubst($1, \(\\[$`\\]\), \\\1), \([$`]\), \\\1){}dnl
  264. changequote([,])])dnl
  265. dnl
  266. dnl Quote $1 against the right hand side of a sed substitution.
  267. define(AC_QUOTE_SED, [changequote({,})dnl
  268. dnl We use \1 instead of \& to avoid an m4 1.0.3 bug.
  269. patsubst($1, \([&\\]\), \\\1){}dnl
  270. changequote([,])])dnl
  271. dnl
  272. dnl Quote $1 against tokenization.
  273. define(AC_QUOTE_TOKEN, [changequote({,})dnl
  274. patsubst($1, \([     ]\), \\\1){}dnl
  275. changequote([,])])dnl
  276. dnl
  277. dnl Subroutine of AC_DEFINE.  Does more quoting magic than any sane person
  278. dnl should be able to understand.  The point of it all is that what goes into
  279. dnl Makefile et al should be verbatim what was written in configure.in.
  280. define(AC_DEFINE_QUOTE, [dnl
  281. AC_QUOTE_TOKEN(AC_QUOTE_SQUOTE(AC_QUOTE_DQUOTE($1)))])dnl
  282. dnl
  283. define(AC_DEFINE_SEDQUOTE, [dnl
  284. AC_QUOTE_DQUOTE(AC_QUOTE_HERE(AC_QUOTE_HERE(AC_QUOTE_SED($1))))])dnl
  285. dnl
  286. dnl Don't compare $2 to a blank, so we can support "-Dfoo=".
  287. dnl If creating a configuration header file, we add
  288. dnl commands to SEDDEFS to define the variable.  SED[due][ABCD]
  289. dnl get defined in config.status.  Here we just insert the
  290. dnl variable parts of the string: the variable name to define
  291. dnl and the value to give it.
  292. define(AC_DEFINE,[{
  293. ifelse($#, 2, test -n "$verbose" && \
  294. echo '    defining' $1 to be 'ifelse($2,, empty, $2)'
  295. DEFS="$DEFS -D$1=AC_DEFINE_QUOTE($2)", test -n "$verbose" && \
  296. echo '    defining' $1
  297. DEFS="$DEFS -D$1=1")dnl
  298. ifdef([AC_CONFIG_NAME],
  299. [
  300. ifelse($#, 2, [SEDDEFS="dnl
  301. ${SEDDEFS}\${SEDdA}$1\${SEDdB}$1\${SEDdC}AC_DEFINE_SEDQUOTE($2)\${SEDdD}
  302. \${SEDuA}$1\${SEDuB}$1\${SEDuC}AC_DEFINE_SEDQUOTE($2)\${SEDuD}
  303. \${SEDeA}$1\${SEDeB}$1\${SEDeC}AC_DEFINE_SEDQUOTE($2)\${SEDeD}
  304. "], [SEDDEFS="${SEDDEFS}\${SEDdA}$1\${SEDdB}$1\${SEDdC}1\${SEDdD}
  305. \${SEDuA}$1\${SEDuB}$1\${SEDuC}1\${SEDuD}
  306. \${SEDeA}$1\${SEDeB}$1\${SEDeC}1\${SEDeD}
  307. "])])
  308. }
  309. ])dnl
  310. dnl
  311. dnl Unsafe version of AC_DEFINE.  
  312. dnl Users are responsible for the quoting nightmare.
  313. dnl Well, not all of it.  We need to pull the identify function out to
  314. dnl the top level, because m4 doesn't really support nested functions;
  315. dnl it doesn't distinguish between the arguments to the outer
  316. dnl function, which should be expanded, and the arguments to the inner
  317. dnl function, which shouldn't yet.
  318. define(AC_IDENTITY,$1)dnl
  319. define(AC_DEFINE_UNQUOTED,[dnl
  320. pushdef([AC_DEFINE_QUOTE],defn([AC_IDENTITY]))dnl
  321. pushdef([AC_DEFINE_SEDQUOTE],defn([AC_IDENTITY]))dnl
  322. AC_DEFINE($1,$2)dnl
  323. popdef([AC_DEFINE_SEDQUOTE])dnl
  324. popdef([AC_DEFINE_QUOTE])dnl
  325. ])dnl
  326. dnl
  327. define(AC_BEFORE,
  328. [ifdef([AC_PROVIDE_$2], [errprint(__file__:__line__: [$2 was called before $1
  329. ])])])dnl
  330. dnl
  331. define(AC_REQUIRE,
  332. [ifdef([AC_PROVIDE_$1],,[indir([$1])
  333. ])])dnl
  334. dnl
  335. define(AC_PROVIDE,
  336. [define([AC_PROVIDE_$1],)])dnl
  337. dnl
  338. dnl
  339. dnl Checks for kinds of features
  340. dnl
  341. dnl
  342. define(AC_PROGRAM_CHECK,
  343. [if test -z "[$]$1"; then
  344.   # Extract the first word of `$2', so it can be a program name with args.
  345.   set dummy $2; word=[$]2
  346.   echo checking for $word
  347.   IFS="${IFS=     }"; saveifs="$IFS"; IFS="${IFS}:"
  348.   for dir in $PATH; do
  349.     test -z "$dir" && dir=.
  350.     if test -f $dir/$word; then
  351.       $1="$3"
  352.       break
  353.     fi
  354.   done
  355.   IFS="$saveifs"
  356. fi
  357. ifelse([$4],,, [test -z "[$]$1" && $1="$4"])
  358. test -n "[$]$1" -a -n "$verbose" && echo "    setting $1 to [$]$1"
  359. AC_SUBST($1)dnl
  360. ])dnl
  361. dnl
  362. define(AC_PROGRAMS_CHECK,
  363. [for p in $2
  364. do
  365. AC_PROGRAM_CHECK($1, [$]p, [$]p, )
  366. test -n "[$]$1" && break
  367. done
  368. ifelse([$3],,, [test -n "[$]$1" || $1="$3"
  369. ])])dnl
  370. dnl
  371. define(AC_HEADER_EGREP,
  372. [AC_REQUIRE([AC_PROG_CPP])AC_PROVIDE([$0])echo '#include <$2>' > conftest.c
  373. eval "$CPP \$DEFS conftest.c > conftest.out 2>&1"
  374. if egrep "$1" conftest.out >/dev/null 2>&1; then
  375.   ifelse([$3], , :, [$3])
  376. ifelse([$4], , , [else
  377.   $4
  378. ])dnl
  379. fi
  380. rm -f conftest*
  381. ])dnl
  382. dnl
  383. dnl Because this macro is used by AC_GCC_TRADITIONAL, which must come early,
  384. dnl it is not included in AC_BEFORE checks.
  385. define(AC_PROGRAM_EGREP,
  386. [AC_REQUIRE([AC_PROG_CPP])AC_PROVIDE([$0])cat > conftest.c <<EOF
  387. [$2]
  388. EOF
  389. eval "$CPP \$DEFS conftest.c > conftest.out 2>&1"
  390. if egrep "$1" conftest.out >/dev/null 2>&1; then
  391.   ifelse([$3], , :, [$3])
  392. ifelse([$4], , , [else
  393.   $4
  394. ])dnl
  395. fi
  396. rm -f conftest*
  397. ])dnl
  398. dnl
  399. define(AC_HEADER_CHECK,
  400. [echo checking for $1
  401. ifelse([$3], , [AC_TEST_CPP([#include <$1>], [$2])],
  402. [AC_TEST_CPP([#include <$1>], [$2], [$3])])
  403. ])dnl
  404. dnl
  405. define(AC_COMPILE_CHECK,
  406. [AC_PROVIDE([$0])dnl
  407. ifelse([$1], , , [echo checking for $1]
  408. )dnl
  409. cat > conftest.c <<EOF
  410. [$2]
  411. int main() { exit(0); }
  412. int t() { [$3] }
  413. EOF
  414. dnl Don't try to run the program, which would prevent cross-configuring.
  415. if eval $compile; then
  416.   ifelse([$4], , :, [$4])
  417. ifelse([$5], , , [else
  418.   $5
  419. ])dnl
  420. fi
  421. rm -f conftest*]
  422. )dnl
  423. dnl
  424. define(AC_TEST_PROGRAM,
  425. [AC_PROVIDE([$0])ifelse([$4], , , [AC_REQUIRE([AC_CROSS_CHECK])if test -n "$cross_compiling"
  426. then
  427.   $4
  428. else
  429. ])dnl
  430. cat > conftest.c <<EOF
  431. [$1]
  432. EOF
  433. eval $compile
  434. if test -s conftest && (./conftest; exit) 2>/dev/null; then
  435.   ifelse([$2], , :, [$2])
  436. ifelse([$3], , , [else
  437.   $3
  438. ])dnl
  439. fi
  440. ifelse([$4], , , fi
  441. )dnl
  442. rm -f conftest*])dnl
  443. dnl
  444. define(AC_TEST_CPP,
  445. [AC_REQUIRE([AC_PROG_CPP])cat > conftest.c <<EOF
  446. [$1]
  447. EOF
  448. dnl Some shells (Coherent) do redirections in the wrong order, so need
  449. dnl the parens.
  450. err=`eval "($CPP \$DEFS conftest.c >/dev/null) 2>&1"`
  451. if test -z "$err"; then
  452.   ifelse([$2], , :, [$2])
  453. ifelse([$3], , , [else
  454.   $3
  455. ])dnl
  456. fi
  457. rm -f conftest*])dnl
  458. dnl
  459. define(AC_REPLACE_FUNCS,
  460. [for func in $1
  461. do
  462. AC_COMPILE_CHECK([${func}], ,
  463. [/* The GNU C library defines this for functions which it implements
  464.     to always fail with ENOSYS.  Some functions are actually named
  465.     something starting with __ and the normal name is an alias.  */
  466. #if defined (__stub_${func}) || defined (__stub___${func})
  467. choke me
  468. #else
  469. /* Override any gcc2 internal prototype to avoid an error.  */
  470. extern char ${func}(); ${func}();
  471. #endif
  472. ], , [LIBOBJS="$LIBOBJS ${func}.o"
  473. test -n "$verbose" && echo "    using ${func}.o instead"])
  474. done
  475. AC_SUBST(LIBOBJS)dnl
  476. ])dnl
  477. dnl
  478. define(AC_FUNC_CHECK,
  479. [ifelse([$3], , [AC_COMPILE_CHECK($1, [#include <ctype.h>], [
  480. /* The GNU C library defines this for functions which it implements
  481.     to always fail with ENOSYS.  Some functions are actually named
  482.     something starting with __ and the normal name is an alias.  */
  483. #if defined (__stub_$1) || defined (__stub___$1)
  484. choke me
  485. #else
  486. /* Override any gcc2 internal prototype to avoid an error.  */
  487. extern char $1(); $1();
  488. #endif
  489. ],
  490. $2)], [AC_COMPILE_CHECK($1, [#include <ctype.h>], [
  491. /* The GNU C library defines this for functions which it implements
  492.     to always fail with ENOSYS.  Some functions are actually named
  493.     something starting with __ and the normal name is an alias.  */
  494. #if defined (__stub_$1) || defined (__stub___$1)
  495. choke me
  496. #else
  497. /* Override any gcc2 internal prototype to avoid an error.  */
  498. extern char $1(); $1();
  499. #endif
  500. ],
  501. $2, $3)])dnl
  502. ])dnl
  503. dnl
  504. define(AC_HAVE_FUNCS,
  505. [for func in $1
  506. do
  507. changequote(,)dnl
  508. trfunc=HAVE_`echo $func | tr '[a-z]' '[A-Z]'`
  509. changequote([,])dnl
  510. AC_FUNC_CHECK(${func},
  511. AC_DEFINE(${trfunc}))dnl
  512. done
  513. ])dnl
  514. dnl
  515. define(AC_HAVE_HEADERS,
  516. [for hdr in $1
  517. do
  518. changequote(,)dnl
  519. trhdr=HAVE_`echo $hdr | tr '[a-z]./' '[A-Z]__'`
  520. changequote([,])dnl
  521. AC_HEADER_CHECK(${hdr},
  522. AC_DEFINE(${trhdr}))dnl
  523. done
  524. ])dnl
  525. dnl
  526. define(AC_HAVE_LIBRARY, [dnl
  527. changequote(/,/)dnl
  528. define(libname, patsubst(patsubst($1, /lib\([^\.]*\)\.a/, /\1/), /-l/, //))dnl
  529. changequote([,])dnl
  530. LIBS_save="${LIBS}"
  531. LIBS="${LIBS} -l[]libname[]"
  532. have_lib=""
  533. AC_COMPILE_CHECK([-l[]libname[]], , [main();], [have_lib="1"])dnl
  534. LIBS="${LIBS_save}"
  535. ifelse($#, 1, [dnl
  536. if test -n "${have_lib}"; then
  537.    AC_DEFINE([HAVE_LIB]translit(libname, [a-z], [A-Z]))
  538.    LIBS="${LIBS} -l[]libname[]"
  539. fi
  540. undefine(libname)dnl
  541. ], [dnl
  542. if test -n "${have_lib}"; then
  543.    :; $2
  544. else
  545.    :; $3
  546. fi
  547. ])])dnl
  548. dnl
  549. dnl
  550. dnl The big finish
  551. dnl
  552. dnl
  553. define(AC_OUTPUT,
  554. [changequote(,)dnl
  555. if test -n "$prefix"; then
  556.   test -z "$exec_prefix" && exec_prefix='${prefix}'
  557.   prsub="s%^prefix\\([     ]*\\)=\\([     ]*\\).*$%prefix\\1=\\2$prefix%"
  558. fi
  559. if test -n "$exec_prefix"; then
  560.   prsub="$prsub
  561. s%^exec_prefix\\([     ]*\\)=\\([     ]*\\).*$%\
  562. exec_prefix\\1=\\2$exec_prefix%"
  563. fi
  564. DEFS="`echo \"$DEFS\" | sed 's%[&\\\]%\\\&%g'`"
  565. changequote([,])dnl
  566. AC_SUBST(LIBS)dnl
  567. AC_SUBST(srcdir)dnl
  568. dnl Substituting for DEFS would confuse sed if it contains multiple lines.
  569. ifdef([AC_CONFIG_NAME],
  570. [divert(1)dnl
  571. s%@DEFS@%-DHAVE_CONFIG_H%],
  572. [divert(1)dnl
  573. s%@DEFS@%$DEFS%]
  574. [divert(2)dnl
  575. DEFS='$DEFS'
  576. ])dnl
  577. divert(2)dnl
  578. prefix='$prefix'
  579. exec_prefix='$exec_prefix'
  580. prsub='$prsub'
  581. divert(0)dnl
  582.  
  583. trap 'rm -f config.status; exit 1' 1 3 15
  584. echo creating config.status
  585. rm -f config.status
  586. cat > config.status <<EOF
  587. #!/bin/sh
  588. # Generated automatically by configure.
  589. # Run this file to recreate the current configuration.
  590. # This directory was configured as follows,
  591. dnl Some hostnames (SVR3.2, Linux) return a bogus exit status so uname
  592. dnl gets run too.
  593. # on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
  594. #
  595. [#] [$]0 [$]*
  596.  
  597. for arg
  598. do
  599.   case "[\$]arg" in
  600.     -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
  601.     exec /bin/sh [$]0 [$]* ;;
  602.     *) echo "Usage: config.status [--recheck]" 2>&1; exit 1 ;;
  603.   esac
  604. done
  605.  
  606. ifdef([AC_CONFIG_NAME],
  607. [trap 'rm -f $1 AC_CONFIG_NAME conftest*; exit 1' 1 3 15],
  608. [trap 'rm -f $1; exit 1' 1 3 15])
  609. undivert(2)dnl
  610. EOF
  611. cat >> config.status <<\EOF
  612.  
  613. top_srcdir=$srcdir
  614. changequote(,)dnl
  615.  
  616. # Allow make-time overrides of the generated file list.
  617. test -n "$gen_files" || gen_files="$1"
  618.  
  619. for file in .. $gen_files; do if [ "x$file" != "x.." ]; then
  620.   srcdir=$top_srcdir
  621.   # Remove last slash and all that follows it.  Not all systems have dirname.
  622.   dir=`echo $file|sed 's%/[^/][^/]*$%%'`
  623. changequote([,])dnl
  624.   if test "$dir" != "$file"; then
  625.     test "$top_srcdir" != . && srcdir=$top_srcdir/$dir
  626.     test ! -d $dir && mkdir $dir
  627.   fi
  628.   echo creating $file
  629.   rm -f $file
  630.   echo "# Generated automatically from `echo $file|sed 's|.*/||'`.in by configure." > $file
  631.   sed -e "
  632. $prsub
  633. undivert(1)dnl
  634. " $top_srcdir/${file}.in >> $file
  635. fi; done
  636. AC_OUTPUT_HEADER
  637. exit 0
  638. EOF
  639. chmod +x config.status
  640. test -n "$no_create" || ./config.status
  641. ])dnl
  642. dnl This is a subroutine of AC_OUTPUT, broken out primarily to avoid bugs
  643. dnl with long definitions in GNU m4 1.0.  This is called inside a quoted
  644. dnl here document whose contents are going into config.status.
  645. define(AC_OUTPUT_HEADER,[dnl
  646. ifdef([AC_CONFIG_NAME],[dnl
  647. test -n "$gen_config" || gen_config=AC_CONFIG_NAME
  648. echo creating $gen_config
  649. changequote(<<,>>)dnl
  650. # These sed commands are put into SEDDEFS when defining a macro.
  651. # They are broken into pieces to make the sed script easier to manage.
  652. # They are passed to sed as "A NAME B NAME C VALUE D", where NAME
  653. # is the cpp macro being defined and VALUE is the value it is being given.
  654. # Each defining turns into a single global substitution command.
  655. #
  656. # SEDd sets the value in "#define NAME VALUE" lines.
  657. SEDdA='s@^\([     ]*\)#\([     ]*define[     ][     ]*\)'
  658. SEDdB='\([     ][     ]*\)[^     ]*@\1#\2'
  659. SEDdC='\3'
  660. SEDdD='@g'
  661. # SEDu turns "#undef NAME" with trailing blanks into "#define NAME VALUE".
  662. SEDuA='s@^\([     ]*\)#\([     ]*\)undef\([     ][     ]*\)'
  663. SEDuB='\([     ]\)@\1#\2define\3'
  664. SEDuC=' '
  665. SEDuD='\4@g'
  666. # SEDe turns "#undef NAME" without trailing blanks into "#define NAME VALUE".
  667. SEDeA='s@^\([     ]*\)#\([     ]*\)undef\([     ][     ]*\)'
  668. SEDeB='<<$>>@\1#\2define\3'
  669. SEDeC=' '
  670. SEDeD='@g'
  671. changequote([,])dnl
  672. rm -f conftest.sed
  673. EOF
  674. # Turn off quoting long enough to insert the sed commands.
  675. rm -f conftest.sh
  676. cat > conftest.sh <<EOF
  677. $SEDDEFS
  678. EOF
  679.  
  680. # Maximum number of lines to put in a single here document.
  681. maxshlines=9
  682.  
  683. # Break up $SEDDEFS (now in conftest.sh) because some shells have a limit
  684. # on the size of here documents.
  685.  
  686. while :
  687. do
  688.   lines=`grep -c . conftest.sh`
  689.   if test -z "$lines" || test "$lines" -eq 0; then break; fi
  690.   rm -f conftest.s1 conftest.s2
  691.   sed ${maxshlines}q conftest.sh > conftest.s1 # Like head -20.
  692.   sed 1,${maxshlines}d conftest.sh > conftest.s2 # Like tail +21.
  693.   # Write a limited-size here document to append to conftest.sed.
  694.   echo 'cat >> conftest.sed <<CONFEOF' >> config.status
  695.   cat conftest.s1 >> config.status
  696.   echo 'CONFEOF' >> config.status
  697.   rm -f conftest.s1 conftest.sh
  698.   mv conftest.s2 conftest.sh
  699. done
  700. rm -f conftest.sh
  701.  
  702. # Now back to your regularly scheduled config.status.
  703. cat >> config.status <<\EOF
  704. # This sed command replaces #undef's with comments.  This is necessary, for
  705. # example, in the case of _POSIX_SOURCE, which is predefined and required
  706. # on some systems where configure will not decide to define it in
  707. [#] AC_CONFIG_NAME.
  708. cat >> conftest.sed <<\CONFEOF
  709. changequote(,)dnl
  710. s,^[     ]*#[     ]*undef[     ][     ]*[a-zA-Z_][a-zA-Z_0-9]*,/* & */,
  711. changequote([,])dnl
  712. CONFEOF
  713. rm -f conftest.h
  714. # Break up the sed commands because old seds have small limits.
  715. maxsedlines=20
  716. cp $top_srcdir/$gen_config.in conftest.h1
  717. while :
  718. do
  719.   lines=`grep -c . conftest.sed`
  720.   if test -z "$lines" || test "$lines" -eq 0; then break; fi
  721.   rm -f conftest.s1 conftest.s2 conftest.h2
  722.   sed ${maxsedlines}q conftest.sed > conftest.s1 # Like head -20.
  723.   sed 1,${maxsedlines}d conftest.sed > conftest.s2 # Like tail +21.
  724.   sed -f conftest.s1 < conftest.h1 > conftest.h2
  725.   rm -f conftest.s1 conftest.h1 conftest.sed
  726.   mv conftest.h2 conftest.h1
  727.   mv conftest.s2 conftest.sed
  728. done
  729. rm -f conftest.sed conftest.h
  730. echo "/* $gen_config.  Generated automatically by configure.  */" > conftest.h
  731. cat conftest.h1 >> conftest.h
  732. rm -f conftest.h1
  733. if cmp -s $gen_config conftest.h 2>/dev/null; then
  734.   # The file exists and we would not be changing it.
  735.   rm -f conftest.h
  736. else
  737.   rm -f $gen_config
  738.   mv conftest.h $gen_config
  739. fi
  740.  
  741. ])])dnl
  742.